package com.czk.grouptask;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

/**
 * 归还组任务
 *
 * @Author ChenZhangKun
 * @Date 2020/9/15 14:05
 */
public class BackGroupTask {
    public static void main(String[] args) {
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //
        TaskService taskService = processEngine.getTaskService();
        Task task = taskService.createTaskQuery()
                .processDefinitionKey("czk")
                .taskAssignee("李洪赭")
                .singleResult();
        //
        if (task!=null){
            // 归还任务，将执行人设置null
           taskService.setAssignee(task.getId(),null);
        }else {
            System.out.println("没有任务");
        }
    }
}
